home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / self / contrib.lha / contrib / 491 / navel / abstractView.self next >
Encoding:
Text File  |  1993-07-18  |  3.4 KB  |  152 lines

  1. "abstractView.self,v 1.3 1993/07/18 20:24:04 richards Exp"
  2. "Abstract views - a simple X interface and widget set for Self"
  3.  
  4. "This contains things common to heavy, and light weight views"
  5.  
  6. traits views _AddSlotsIfAbsent: (| ^ abstractView = () |)
  7. traits views abstractView _Define: (|
  8.     parent*** = traits clonable.
  9.     
  10.     ^ copy = (copyUnrealised).
  11.     ^ copyUnrealised = (copyUnrealised: nil).
  12.     
  13.     "should only be called indirectly (see above)
  14.      but this is the place to override copy"
  15.  
  16.     "this code must be kept in step with the unrealise code"
  17.     
  18.     "_" copyUnrealised: sv = (|c|
  19.     c: resend.copy.
  20.     
  21.     "link ourselves in properly"
  22.     c superView: sv.
  23.     
  24.     "the follow copied"
  25.     c iArea: iArea copy.
  26.     
  27.     c
  28.     ).
  29.  
  30.     sizing* = (|
  31.     ^ area = (iArea copy).
  32.     ^ x = (iArea left).
  33.     ^ y = (iArea top).
  34.     ^ width = (iArea width).
  35.     ^ height = (iArea height).
  36.     
  37.     ^ area: a = (
  38.         "should really generate a size-changed event here ourselves"
  39.         "what about top-level windows?"
  40.         (a == iArea) ifTrue: [^self].
  41.         isRealised ifTrue: [window
  42.               moveResizeX: a left 
  43.               Y: a top
  44.               W: a width
  45.               H: a height]
  46.           False: [iArea: a].
  47.         self
  48.     ).
  49.  
  50.     ^ includes: pt = (
  51.         area includes: pt
  52.     ).
  53.     
  54.     ^ translateTo: pt = (
  55.         area: area translateTo: pt.
  56.     ).
  57.     |).
  58.     
  59.     parameters* = (|
  60.     ^ borderWidth = (iBorderWidth).
  61.     ^ borderColour = (iBorderColour).
  62.     ^ background = (iBackground).
  63.     |).
  64.     
  65.     naming* = (|
  66.     ^ markPrefix <- ''.
  67.     ^ name = (iName).
  68.     ^ iconName = (('' >= iIconName) ifTrue: iName False: iIconName).
  69.     ^ name: str = (
  70.         iName: str.
  71.         ifRealised: [
  72.         window name: markPrefix,str.
  73.         window iconName: markPrefix,iconName]).
  74.     ^ iconName: str = (
  75.         iIconName: str. 
  76.         ifRealised: [window iconName: markPrefix,str]).
  77.     ^ icon = (iIcon).
  78.     ^ icon: str = (
  79.         iIcon: str.
  80.         (isRealised && [icon != '']) ifTrue: 
  81.           [window iconified: false 
  82.               Icon: (findBitmap: icon) Input: true]).
  83.     |).
  84.     
  85.     "composite defines this, of course"
  86.     subViews* = (|
  87.     ^ isTopView = (superView isNil).
  88.     ^ topView = (superView isNil ifTrue: [self] False: [superView topView]).
  89.     
  90.     ^ addSubView: v = (notCompoundView).
  91.     ^ removeSubView: v = (notCompoundView).
  92.     
  93.     ^ addToSuperView: v = (v addSubView: self).
  94.     ^ removeFromSuperView = 
  95.           (superView notNil ifTrue: [superView removeSubView: self]. self).
  96.     
  97.     ^ setSuperView: sv = (
  98.         superView: sv.
  99.     ).
  100.     |).
  101.  
  102.     events* = (|
  103.     configureNotify: event = (iArea: event area).
  104.     |).
  105.  
  106.     errors* = (|
  107.     _ notCompoundView = (error: 'This is not a composite view').
  108.     _ notYetImplememted: feetcher = 
  109.           (warning: ('Feature: 'feetcher,' is not yet implemented'). self).
  110.     _ dunno = (error: 'I dunno..').
  111.     ^ debugMessage: m = (viewManager debugMessage: m).
  112.     |).    
  113.  
  114.     modelling* = (|
  115.     ^ model: m = (iModel: m).
  116.     ^ model = (iModel).
  117.     
  118.     ^ noModel = (model: defaultModel).
  119.     
  120.     _ defaultModel = nil.
  121.     |).
  122.     
  123.     hacks* = (|
  124.     "This is a hack!"
  125.     "_" findBitmap: name = (manager findBitmap: name Window: window).
  126.     |).
  127.     
  128.     printing* = (|
  129.     printString = ('abstractView: ',iName).
  130.     |).
  131.     
  132. |)
  133.  
  134.  
  135. prototypes views _AddSlotsIfAbsent: (| ^ abstractView = () |)
  136. prototypes views abstractView _Define: (|
  137.     parent* = traits abstractView.
  138.     
  139.     _ thisObjectPrints = true.
  140.     
  141.     ^_ superView <- nil.
  142.     
  143.     "_" iArea <- (10@10)##(300@@300).
  144.  
  145.     "_" iModel.
  146.  
  147.     _ iName <- 'view'.
  148.     _ iIconName <- ''.
  149.     _ iIcon <- ''.
  150. |)
  151.  
  152.